#include <stdarg.h>
#include <stddef.h>

namespace CERT_VA_ARG_TYPE {

	namespace bad {
		void func1(size_t num_vargs, ...)
		{
			va_list ap;
			va_start(ap, num_vargs);
			if (num_vargs > 0) {
				unsigned char c = va_arg(ap, unsigned char);
				// ...
			}
			va_end(ap);
		}

		void func2(size_t num_vargs, ...)
		{
			va_list ap;
			va_start(ap, num_vargs);
			if (num_vargs > 0) {
				float var = va_arg(ap, float);
				// ...
			}
			va_end(ap);
		}

		void f(void)
		{
			unsigned char c = 0x12;
			float d = 1.25;
			func1(1, c);
			func2(1, d);
		}
	
	}
	

	namespace good {
		void func1(size_t num_vargs, ...)
		{
			va_list ap;
			va_start(ap, num_vargs);
			if (num_vargs > 0) {
				unsigned char c = (unsigned char)va_arg(ap, int);
				// ...
			}
			va_end(ap);
		}

		void func2(size_t num_vargs, ...)
		{
			va_list ap;
			va_start(ap, num_vargs);
			if (num_vargs > 0) {
				double var1 = va_arg(ap, double);
				// ...
			}
			va_end(ap);
		}

		void f(void)
		{
			int i = 10;
			double d = 10.234;
			func1(1, i);
			func2(1, d);
		}
	}
}